//
//  MapUtils.m
//  citzenWorkStation
//
//  Created by yang qing on 2018/3/7.
//  Copyright © 2018年 yang qing. All rights reserved.
//

#import "MapUtils.h"

@implementation MapUtils
//经纬度转墨卡托
+(MyPoint*)lonLat2Mercator:(MyPoint *) latLon{
    double x=latLon.lon *20037508.34/180;
    double y =log(tan((90+latLon.lat)*M_PI/360))/(M_PI/180);
    y = y *20037508.34/180;
    latLon.x = x;
    latLon.y = y;
    return latLon;
}
//墨卡托转经纬度
+(MyPoint*)Mercator2lonLat:(MyPoint *) mercator{
    double lon = mercator.x/20037508.34*180;
    double lat = mercator.y/20037508.34*180;
    lat= 180/M_PI*(2*atan(exp(lat*M_PI/180))-M_PI/2);
    mercator.lat = lat;
    mercator.lon = lon;
    return mercator;
}
@end

////经纬度转墨卡托
//-(CGPoint )lonLat2Mercator:(CGPoint ) lonLat
//{
//    CGPoint mercator;
//    double x = lonLat.x *20037508.34/180;
//    double y = log(tan((90+lonLat.y)*M_PI/360))/(M_PI/180);
//    y = y *20037508.34/180;
//    mercator.x = x;
//    mercator.y = y;
//    return mercator ;
//}
//
////墨卡托转经纬度
//-(CGPoint )Mercator2lonLat:(CGPoint ) mercator
//{
//    CGPoint lonLat;
//    double x = mercator.x/20037508.34*180;
//    double y = mercator.y/20037508.34*180;
//    y= 180/M_PI*(2*atan(exp(y*M_PI/180))-M_PI/2);
//    lonLat.x = x;
//    lonLat.y = y;
//    return lonLat;
//}

